home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 43
/
Mac Magazin and MacEasy Magazine CD - Issue 43.iso
/
Software
/
Mobiles Büro
/
Newton
/
Newton Entwickler
/
DIL 2.0 Sample Code ƒ
/
SoupDrink-Mac-4
/
AppDialogs.c
< prev
next >
Wrap
Text File
|
1996-05-23
|
3KB
|
142 lines
/*
** File: AppDialogs.c
**
** Contains: Input and status utitiles for MacOS SoupDrink application
** For the main MacOS file, see "SoupDrink.c" in this folder
** For the main Windows file, see "SOUPDRNK.C" in the Windows folder
**
** Nearly all of the DIL code can be found in the file "engine.c".
**
** Written by: Rob Langhorne, mods by David Fedor
**
** Copyright © 1995-1996 by Apple Computer, Inc. All rights reserved.
**
** You may incorporate this sample code into your applications without
** restriction. This sample code has been provided "AS IS" and the
** responsibility for its operation is 100% yours. You are not
** permitted to modify and redistribute the source as "DTS Sample Code."
** If you are going to re-distribute the source, we require that you
** make it clear in the source that the code was descended from
** Apple-provided sample code, but that you've made changes.
*/
#include <Dialogs.h>
#include <String.h>
#include <Strings.h>
#include "AppDialogs.h"
// ok_outline
//
// outlines the "OK" button with a heavy border
ok_outline(DialogPtr theDialog,short item)
{
CGrafPtr oldPort;
short itemType;
Rect itemRect;
Handle itemHdl;
GetDItem(theDialog,item,&itemType,&itemHdl,&itemRect);
if((**(ControlHandle)itemHdl).contrlHilite == 0xff) /* cntrl is inactive */
return 0;
GetPort( (GrafPtr *)&oldPort);
SetPort(theDialog);
PenSize(3,3);
InsetRect(&itemRect,-4,-4);
FrameRoundRect(&itemRect,16,16);
PenSize(1,1);
SetPort( (GrafPtr)oldPort);
return 0;
}
Boolean inputDialog(char *inputText, char* initString, char* label)
{
DialogRecord Dialog;
short Item;
short itemType;
Rect itemRect;
Handle txHdl;
Str255 tempStr ;
Str255 initStr ;
GetNewDialog (kInputDialog, &Dialog, (WindowPtr)-1); /***** errors? */
GetDItem((DialogPtr)&Dialog, LABEL, &itemType, &txHdl, &itemRect);
strcpy((char*) initStr, label);
c2pstr((char*) initStr);
SetIText(txHdl,initStr);
GetDItem((DialogPtr)&Dialog, INPUT_TEXT, &itemType, &txHdl, &itemRect);
strcpy((char*) initStr, initString);
c2pstr((char*) initStr);
SetIText(txHdl,initStr);
SelIText((DialogPtr)&Dialog, INPUT_TEXT, 0, 32767); // select the text for them, in case they want to change it
ok_outline ((DialogPtr)&Dialog, OK) ;
do
{
ModalDialog (NULL, &Item);
} while ((Item != OK) && (Item != CANCEL)) ;
if (Item == OK)
{
GetIText(txHdl,tempStr);
p2cstr(tempStr);
strcpy(inputText, (char *)tempStr);
}
else
*inputText = '\0'; // zero-length string indicates cancel.
CloseDialog ((DialogPtr)&Dialog);
return true;
}
void PostAlertMessage(char*a, char*b, char*c, char*d)
{
Str255 aa, bb, cc, dd;
strcpy(( char*) aa, a); strcpy(( char*) bb, b);
strcpy(( char*) cc, c); strcpy(( char*) dd, d);
ParamText(c2pstr((char*)aa), c2pstr((char*)bb), c2pstr((char*)cc), c2pstr((char*)dd));
Alert(kInfoDialog, nil);
}
/*
* ShowSplash
*
* Show our splash screen
*/
void ShowSplash(DialogPtr *splash)
{
long pause; // For use in delay
Handle Hdl=nil;
*splash = GetNewDialog(kSplashDialog, nil, (WindowPtr)-1) ;
if (*splash) {
SetPort(*splash);
ShowWindow(*splash);
DrawDialog(*splash);
Delay(60L,&pause);
}
}
/*
* HideSplash
*
* Hide our splash screen
*/
void HideSplash(DialogPtr splash)
{
if (splash) {
HideWindow(splash);
DisposeDialog(splash);
}
}